<template>
  <div class="nav-bar z-index-max"
       :style="navBarStyle">
    <div class="left"
         @click="$emit('onLeftClick')">
      <img src="@img/back.svg"
           v-if="isBack">
      <slot name="nav-left"></slot>
    </div>
    <div class="center">
      <span class="page-title"
            v-if="pageName">{{pageName}}</span>
      <slot name="nav-center"></slot>
    </div>
    <div class="right">
      <slot name="nav-right"></slot>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    pageName: {
      type: String,
      required: false,
      default: ''
    },
    isBack: {
      type: Boolean,
      required: false,
      default: true
    },
    navBarStyle: {
      type: Object,
      default: () => {
        return {
          backgroundColor: 'white'
        }
      }
    }
  }
}
</script>
<style scoped lang = 'scss'>
@import "@css/style.scss";
@import "@css/variable.scss";
.nav-bar {
  width: 100%;
  height: px2rem(44);
  line-height: px2rem(44);
  display: flex;
  justify-content: space-between;
  .left,
  .right {
    display: flex;
    height: 100%;
    width: px2rem(26);
    padding: 0 px2rem(8);
    img {
      width: 100%;
      align-self: center;
    }
  }
  .center {
    height: 100%;
    display: flex;
    flex-grow: 1;
    justify-content: center;
    .page-title {
      font-size: px2rem($titleSize);
      align-self: center;
    }
  }
}
</style>